package com.orhon.smartcampus.modules.student.mm;


import java.util.List;

import org.mapstruct.InheritConfiguration;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers;

import com.orhon.smartcampus.modules.base.mm.DictionaryMapper;
import com.orhon.smartcampus.modules.base.mm.LangMapper;
import com.orhon.smartcampus.modules.base.mm.RegionMapper;
import com.orhon.smartcampus.modules.base.mm.SchoolMapper;
import com.orhon.smartcampus.modules.student.entity.SInformation;
import com.orhon.smartcampus.modules.student.gqlModel.GQLStudent;
import com.orhon.smartcampus.modules.user.mm.UserMapper;

@Mapper(
        uses = {
                SchoolMapper.class,
                LangMapper.class,
                RegionMapper.class,
                DictionaryMapper.class,
                UserMapper.class
        }
)
public interface StudentMapper {

    StudentMapper MAPPER = Mappers.getMapper(StudentMapper.class);
    
    @Mapping(source = "id" , target = "id")
    @Mapping(source = "student_number" , target = "number")
    @Mapping(source = "student_learncode" , target = "learn_code")
    @Mapping(source = "student_name" , target = "name")//lang
    @Mapping(source = "pinyin_name" , target = "pinyin_name")
    @Mapping(source = "country" , target = "country",qualifiedByName = "str2dic")
    @Mapping(source = "idcard" , target = "idcard")
    @Mapping(source = "birthday" , target = "birthday")
    @Mapping(source = "sex" , target = "gender", qualifiedByName = "str2dic")
    @Mapping(source = "picture" , target = "picture")
    @Mapping(source = "native_place" , target = "native_place")//lang
    @Mapping(source = "nation" , target = "nation", qualifiedByName = "str2dic")
    @Mapping(source = "hkmtb" , target = "hkmtb")
    @Mapping(source = "political" , target = "political", qualifiedByName = "str2dic")
    @Mapping(source = "speciality" , target = "speciality")//lang
    @Mapping(source = "identity_ivalidity" , target = "identity_ivalidity")
    @Mapping(source = "blood" , target = "blood", qualifiedByName = "str2dic")
    @Mapping(source = "tel_number" , target = "tel_number")
    @Mapping(source = "email" , target = "email")
    @Mapping(source = "postal_code" , target = "postal_code")
    @Mapping(source = "home_page" , target = "home_page")
    @Mapping(source = "household_register_type" , target = "household_register_type", qualifiedByName = "str2dic")
    @Mapping(source = "birth_place" , target = "birth_place")//lang
    @Mapping(source = "present_address" , target = "present_address")
    @Mapping(source = "corresponding_address" , target = "corresponding_address")
    @Mapping(source = "family_address" , target = "family_address")
    @Mapping(source = "household_registed_id" , target = "household_registed", qualifiedByName = "str2reg")
    @Mapping(source = "household_registed_city_id" , target = "household_registed_city", qualifiedByName = "str2reg")
    @Mapping(source = "household_registed_county_id" , target = "household_registed_county", qualifiedByName = "str2reg")
    @Mapping(source = "cradkind_id" , target = "card_type", qualifiedByName = "str2dic")
    @Mapping(source = "is_onlychild" , target = "is_onlychild")
    @Mapping(source = "is_pre_school_education" , target = "is_pre_school_education")
    @Mapping(source = "is_left_behind_children" , target = "is_left_behind_children")
    @Mapping(source = "is_orphan" , target = "is_orphan")
    @Mapping(source = "is_martyr" , target = "is_martyr")
    @Mapping(source = "is_study_in_class" , target = "is_study_in_class")
    @Mapping(source = "is_government_degree" , target = "is_government_degree")
    @Mapping(source = "is_funding" , target = "is_funding")
    @Mapping(source = "is_supplement" , target = "is_supplement")
    @Mapping(source = "is_move_with" , target = "is_move_with")
    @Mapping(source = "disabled_status" , target = "disabled_status", qualifiedByName = "str2dic")
    @Mapping(source = "health" , target = "health", qualifiedByName = "str2dic")
    @Mapping(source = "created_at" , target = "created_at")
    @Mapping(source = "updated_at" , target = "updated_at")
    @Mapping(source = "deleted_at" , target = "deleted_at")
    @Mapping(ignore = true, target = "user" )//用户
    @Mapping(ignore = true, target = "school")//学校
    GQLStudent toStudent(SInformation entity);

    @InheritConfiguration(name = "toStudent")
    List<GQLStudent> toStudentList(List<SInformation> entities);


}
